﻿<UserControl x:Class="FIFP.DashBoard.Views.UCFilter"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:local="clr-namespace:FIFP.DashBoard.Views"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:Presentation="clr-namespace:FIFP.Common.Behaviors.CommonEventArgs;assembly=FIFP.Common"
    DataContext="{Binding FilterVM,Source={StaticResource ServiceLocator}}"
    mc:Ignorable="d">

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <ScrollViewer Grid.Column="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Style="{StaticResource ScrollViewerStyle1}" Margin="0">
            <Grid Margin="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" TextWrapping="Wrap" Text="Start Date" Style="{StaticResource SmallHeading}" VerticalAlignment="Top" Margin="0,5,0,0" Visibility="{Binding IsDateTimeVisibility}" />
                <sdk:DatePicker Name="startdatePicker" Width="190" DisplayDate="{Binding StartDate, Mode=TwoWay,StringFormat='dd/MM/yyyy'}" SelectedDate="{Binding StartDate, Mode=TwoWay}" HorizontalAlignment="Left" Style="{StaticResource DatePickerStyle}" CalendarStyle="{StaticResource CalendarStyle}" Margin="0" d:LayoutOverrides="Height" Grid.Row="1" Visibility="{Binding IsDateTimeVisibility}" FontFamily="Calibri" FontSize="17.333">
                    <!--<i:Interaction.Triggers>
                    <i:EventTrigger  EventName="SelectedDateChanged">
                        <i:InvokeCommandAction Command="{Binding SelectedStartDateChangedCommand}" 
        							CommandParameter="{Binding ElementName=startdatePicker}"  />
                    </i:EventTrigger>
                    <i:EventTrigger  EventName="Loaded">
                        <i:InvokeCommandAction Command="{Binding StartDateLoadedCommand}" 
        							CommandParameter="{Binding ElementName=startdatePicker}"  />
                    </i:EventTrigger>
                </i:Interaction.Triggers>-->
                </sdk:DatePicker>
                <TextBlock TextWrapping="Wrap" Text="End Date" Style="{StaticResource SmallHeading}" VerticalAlignment="Top" Grid.Row="2" Margin="0,5,0,0" Visibility="{Binding IsDateTimeVisibility}" />
                <sdk:DatePicker Name="endDatePicker" Width="190" DisplayDate="{Binding EndDate, Mode=TwoWay,StringFormat='dd/MM/yyyy'}" SelectedDate="{Binding EndDate, Mode=TwoWay}" HorizontalAlignment="Left" Style="{StaticResource DatePickerStyle}" CalendarStyle="{StaticResource CalendarStyle}" Margin="0" Grid.Row="3" d:LayoutOverrides="Height" Visibility="{Binding IsDateTimeVisibility}" FontFamily="Calibri" FontSize="17.333">
                    <i:Interaction.Triggers>
                        <i:EventTrigger  EventName="KeyDown">
                            <Presentation:InvokeDelegateCommandAction
                                    Command="{Binding Source={StaticResource ServiceLocator},Path=FilterVM.FilterByEnterKeyCommand}"
                                    CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </sdk:DatePicker>
                <TextBlock TextWrapping="Wrap" Text="Division Filter" Style="{StaticResource SmallHeading}" VerticalAlignment="Top" Grid.Row="4" Margin="0,10,0,0"/>
                <ComboBox x:Name="cmbDivision"  IsEnabled="{Binding IsDivisionEnabled}" ItemsSource="{Binding DivisionList}" SelectedItem="{Binding SelectedDivision, Mode=TwoWay}"  Margin="0" Grid.Row="5" VerticalAlignment="Top" Style="{StaticResource ComboBoxStyleNew}" Height="30" ItemContainerStyle="{StaticResource ComboBoxItemStyle}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger  EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding DivisionSelectionCommand}" 
        							CommandParameter="{Binding ElementName=cmbDivision}"  />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </ComboBox>

                <Grid Margin="0,5,0,0" Background="Black" Grid.Row="6">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <CheckBox Name="chkAll" ClickMode="Press" Tag="all" Content="Check/Uncheck All" IsChecked="{Binding AllCheckedUnchecked,Mode=TwoWay}" Command="{Binding Source={StaticResource ServiceLocator},Path=FilterVM.CheckedUnCheckedEvent}" CommandParameter="{Binding ElementName=chkAll}" Style="{StaticResource CheckBoxStyle}" Margin="10,15,0,3" />
                       
                      
                  
                    
                    <Border Grid.Row="1" BorderThickness="0" Margin="1,5,1,0" Background="{StaticResource FilterBackground}">
                        <TextBlock TextWrapping="Wrap" Text="Fluid Filter" Style="{StaticResource SmallHeading}" VerticalAlignment="Center" Margin="5,0"/>
                    </Border>

                    <ListBox Margin="3,5,5,0" Grid.Row="2" ItemsSource="{Binding FluidList}" Background="#FF000000" BorderBrush="{x:Null}" ItemContainerStyle="{StaticResource ListBoxItemStyle1}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <CheckBox Name="chkFluid" ClickMode="Press" Visibility="{Binding ItemVisibility}" Tag="{Binding FilterTypeId}" Content="{Binding FilterTypeName}" IsChecked="{Binding ItemChecked,Mode=TwoWay}" Command="{Binding Source={StaticResource ServiceLocator},Path=FilterVM.CheckedFluidEvent}" CommandParameter="{Binding ElementName=chkFluid}" Style="{StaticResource CheckBoxStyle}" Margin="0,0,0,3" >
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger  EventName="KeyDown">
                                            <Presentation:InvokeDelegateCommandAction
                                    Command="{Binding Source={StaticResource ServiceLocator},Path=FilterVM.FilterByEnterKeyCommand}"
                                    CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </CheckBox>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>



                    <Border BorderThickness="0" Margin="0" Background="#FF353C48}" Grid.Row="3" Visibility="{Binding IsCombinedTowerVisibility}">
                        <Border BorderThickness="0" Margin="0,2" Background="{StaticResource FilterBlackBackground}" VerticalAlignment="Center">
                            <CheckBox Name="chkCT" ClickMode="Press" IsChecked="{Binding IsCombinedTowerChecked}" Command="{Binding Path=CombinedTowerEvent}" CommandParameter="{Binding ElementName=chkCT}" Content="Combined towers" Style="{StaticResource CheckBoxStyle}" Margin="5,2">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger  EventName="KeyDown">
                                        <Presentation:InvokeDelegateCommandAction
                                    Command="{Binding Source={StaticResource ServiceLocator},Path=FilterVM.FilterByEnterKeyCommand}"
                                    CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </CheckBox>
                        </Border>
                    </Border>
                    <Border BorderThickness="0" Margin="1,5,1,0" Background="{StaticResource FilterBackground}" Grid.Row="4">
                        <TextBlock TextWrapping="Wrap" Text="UnitType Filter" Style="{StaticResource SmallHeading}" VerticalAlignment="Center" Margin="5,0"/>
                    </Border>
                    <ListBox Margin="3,5,5,0" Grid.Row="5" ItemsSource="{Binding UnitTypeList}" Background="#FF000000" BorderBrush="{x:Null}" ItemContainerStyle="{StaticResource ListBoxItemStyle1}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <CheckBox Name="chkUnitType" ClickMode="Press" Visibility="{Binding ItemVisibility}" Tag="{Binding FilterTypeId}" Content="{Binding FilterTypeName}" IsChecked="{Binding ItemChecked,Mode=TwoWay}" Command="{Binding Source={StaticResource ServiceLocator},Path=FilterVM.CheckedUnitTypeEvent}" CommandParameter="{Binding ElementName=chkUnitType}" Style="{StaticResource CheckBoxStyle}" Margin="0,0,0,3">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger  EventName="KeyDown">
                                            <Presentation:InvokeDelegateCommandAction
                                    Command="{Binding Source={StaticResource ServiceLocator},Path=FilterVM.FilterByEnterKeyCommand}"
                                    CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </CheckBox>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>


                    <Border BorderThickness="0" Margin="1,5,1,0" Background="{StaticResource FilterBackground}" Grid.Row="6">
                        <TextBlock TextWrapping="Wrap" Text="Facility Filter" Style="{StaticResource SmallHeading}" VerticalAlignment="Center" Margin="5,0"/>
                    </Border>


                    <ListBox Margin="3,5,5,5" Grid.Row="7" ItemsSource="{Binding FacilityList}" Background="#FF000000" BorderBrush="{x:Null}" ItemContainerStyle="{StaticResource ListBoxItemStyle1}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <CheckBox Name="chkFacility" ClickMode="Press" Visibility="{Binding ItemVisibility}" Tag="{Binding FilterTypeId}" Content="{Binding FilterTypeName}" IsChecked="{Binding ItemChecked,Mode=TwoWay}" Command="{Binding Source={StaticResource ServiceLocator},Path=FilterVM.CheckedUnitTypeEvent}" CommandParameter="{Binding ElementName=chkFacility}" Style="{StaticResource CheckBoxStyle}" Margin="0,0,0,3">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger  EventName="KeyDown">
                                            <Presentation:InvokeDelegateCommandAction
                                    Command="{Binding Source={StaticResource ServiceLocator},Path=FilterVM.FilterByEnterKeyCommand}"
                                    CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </CheckBox>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            </Grid>
        </ScrollViewer>
        <Button x:Name="btnFilter1" Content="Filter" IsEnabled="{Binding IsFilterEnabled}" Margin="0,5,0,5" Width="160" Style="{StaticResource OverlapButtonStyle}" Grid.Row="7" HorizontalAlignment="Left" VerticalAlignment="Center" Cursor="Hand">
            <i:Interaction.Triggers>
                <i:EventTrigger  EventName="Click">
                    <i:InvokeCommandAction Command="{Binding FilterCommand}" 
        				CommandParameter="{Binding ElementName=btnFilter}" />
                </i:EventTrigger>
                <i:EventTrigger  EventName="KeyDown">
                    <Presentation:InvokeDelegateCommandAction
        				Command="{Binding FilterVM.FilterByEnterKeyCommand, Source={StaticResource ServiceLocator}}"
        				CommandParameter="{Binding InvokeParameter, RelativeSource={RelativeSource Self}}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
    </Grid>
</UserControl>
